home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12731 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  48 lines

  1. Path: hops.cs.jhu.edu!lasher
  2. From: lasher@hops.cs.jhu.edu (John E. Davis)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help!  Can't read input from keyboard!
  5. Date: 2 Apr 1996 03:36:24 GMT
  6. Organization: JHU computer science
  7. Message-ID: <4jq7bo$qc2@blaze.cs.jhu.edu>
  8. References: <4jq0ts$5mh@taniemarie.solon.com>
  9. NNTP-Posting-Host: hops.cs.jhu.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Peter Seebach (seebs@taniemarie.solon.com) expostulated:
  13. > I guess I thought I knew C, but maybe not.  The following program compiles
  14. > without error with
  15.  
  16. > gcc -g -O -Wa,ll -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
  17.  
  18. > but doesn't print 3!  I thought scanf and printf were asymptotic.
  19.  
  20. >     #include <stdio.h>
  21.  
  22. >     int main(void) {
  23. >         int i = 0;
  24.  
  25. >         (void) sscanf, "3", "%d", i;
  26.  
  27. >         (void) printf, "%d", i;
  28.  
  29. >         return 0;
  30. >     }
  31.  
  32. > Can anyone help?  I have cast sscanf() to void to prevent it from
  33. > erroring.
  34.  
  35. > -s
  36.  
  37. i know that in scanf() the variable that the input is stored in needs to 
  38. be the address of the variable. ie: &i  maybe it is different with 
  39. sscanf() though. 
  40.  
  41. --
  42. John Davis
  43. lasher@hops.cs.jhu.edu
  44. http://hops.cs.jhu.edu/~lasher
  45.  
  46. UNIX is a very user-friendly operating system 
  47.  it's just picky about who it's friends with.
  48.